package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Shader.TileMode;
import android.os.Bundle;
import android.view.View;

public class BitmapSdr extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyView vw = new MyView(this);
		setContentView(vw);
	}
	
	class MyView extends View{

		public MyView(Context context) {
			super(context);
		}
		
		public void onDraw(Canvas canvas){
			Paint pnt = new Paint();
			pnt.setAntiAlias(true);
			
			Bitmap clover = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.clover);
			
			pnt.setShader(new BitmapShader(clover, TileMode.REPEAT, TileMode.REPEAT));
			canvas.drawRect(0, 0, 320,150, pnt);
			pnt.setShader(new BitmapShader(clover, TileMode.MIRROR, TileMode.REPEAT));
			canvas.drawRect(0, 160, 320,310, pnt);
		}
	}
}
